﻿namespace QLPhongKham.UC
{
    using ConfigDatabase.Class;
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraTab;
    using QLPhongKham.Access.BenhNhan;
    using QLPhongKham.BaseClass.Chung;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class ucbn_thongso : XtraUserControl
    {
        private ConnectDatabase _condata;
        private BNThongSo _tsbn;
        private SimpleButton btnketthuc;
        private SimpleButton btnluu;
        private LookUpEdit cbbdangnhap;
        private CheckBox chkcm_a1;
        private CheckBox chkcm_a2;
        private CheckBox chkcm_a3;
        private IContainer components = null;
        private Label label2;
        private Label label25;
        private Label label5;
        private XtraTabPage tabkhambenh;
        private ToolTipController toolTipController1;
        private TextEdit txta4;
        private XtraTabControl xtraTabControl1;

        public ucbn_thongso()
        {
            this.InitializeComponent();
        }

        private void btnketthuc_Click(object sender, EventArgs e)
        {
            try
            {
                XtraTabPage parent = (XtraTabPage) base.Parent;
                XtraTabControl control = (XtraTabControl) parent.Parent;
                control.TabPages.Remove(parent);
            }
            catch
            {
                try
                {
                    XtraUserControl control2 = (XtraUserControl) base.Parent;
                    control2.Controls.Remove(this);
                }
                catch
                {
                    ((Form) base.Parent).Close();
                }
            }
        }

        private void btnluu_Click(object sender, EventArgs e)
        {
            this.f_thongso_save(Convert.ToInt16(this.cbbdangnhap.EditValue));
            MessageBox.Show("Lưu th\x00e0nh c\x00f4ng.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK);
        }

        private void cbbdangnhap_EditValueChanged(object sender, EventArgs e)
        {
            try
            {
                this.f_thongso_load(Convert.ToInt16(this.cbbdangnhap.EditValue));
            }
            catch
            {
                this.f_thongso_load(0);
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void f_loaddata_dmdangnhap()
        {
            this.cbbdangnhap.Properties.DataSource = new dtoDMDangNhap(this._condata).LoadAll();
            this.cbbdangnhap.Properties.DisplayMember = "tennguoidung";
            this.cbbdangnhap.Properties.ValueMember = "id";
        }

        private void f_thongso_load(int iddangnhap)
        {
            this.chkcm_a1.Checked = this._tsbn.pKB_A1_CapToaNgoaiVien(iddangnhap);
            this.chkcm_a2.Checked = this._tsbn.pKB_A2_CapToaNoiVien(iddangnhap);
            this.chkcm_a3.Checked = this._tsbn.pTD_A3_SuaThongTinBenhNhan(iddangnhap);
            this.txta4.EditValue = this._tsbn.pKB_A4_SoNgayBNChoKB(iddangnhap);
        }

        private void f_thongso_save(int iddangnhap)
        {
            this._tsbn.pKB_A1_CapToaNgoaiVien_set(this.chkcm_a1.Checked ? "1" : "0", iddangnhap);
            this._tsbn.pKB_A2_CapToaNoiVien_set(this.chkcm_a2.Checked ? "1" : "0", iddangnhap);
            this._tsbn.pTD_A3_SuaThongTinBenhNhan_set(this.chkcm_a3.Checked ? "1" : "0", iddangnhap);
            this._tsbn.pKB_A4_SoNgayBNChoKB_set(this.txta4.EditValue.ToString(), iddangnhap);
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(ucbn_thongso));
            this.btnketthuc = new SimpleButton();
            this.btnluu = new SimpleButton();
            this.label25 = new Label();
            this.xtraTabControl1 = new XtraTabControl();
            this.tabkhambenh = new XtraTabPage();
            this.label2 = new Label();
            this.cbbdangnhap = new LookUpEdit();
            this.chkcm_a3 = new CheckBox();
            this.chkcm_a2 = new CheckBox();
            this.chkcm_a1 = new CheckBox();
            this.toolTipController1 = new ToolTipController(this.components);
            this.txta4 = new TextEdit();
            this.label5 = new Label();
            this.xtraTabControl1.BeginInit();
            this.xtraTabControl1.SuspendLayout();
            this.tabkhambenh.SuspendLayout();
            this.cbbdangnhap.Properties.BeginInit();
            this.txta4.Properties.BeginInit();
            base.SuspendLayout();
            this.btnketthuc.Anchor = AnchorStyles.Bottom;
            this.btnketthuc.Appearance.Options.UseTextOptions = true;
            this.btnketthuc.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnketthuc.Image = Properties.Resources.imgclose;// (Image)manager.GetObject("btnketthuc.Image");
            this.btnketthuc.Location = new Point(0x15a, 0x189);
            this.btnketthuc.Name = "btnketthuc";
            this.btnketthuc.Size = new Size(0x4f, 0x17);
            this.btnketthuc.TabIndex = 3;
            this.btnketthuc.Text = " &Kết th\x00fac";
            this.btnketthuc.Click += new EventHandler(this.btnketthuc_Click);
            this.btnluu.Anchor = AnchorStyles.Bottom;
            this.btnluu.Appearance.Options.UseTextOptions = true;
            this.btnluu.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnluu.Image = Properties.Resources.imgsave;// (Image)manager.GetObject("btnluu.Image");
            this.btnluu.Location = new Point(0x117, 0x189);
            this.btnluu.Name = "btnluu";
            this.btnluu.Size = new Size(0x3f, 0x17);
            this.btnluu.TabIndex = 2;
            this.btnluu.Text = " &Lưu";
            this.btnluu.Click += new EventHandler(this.btnluu_Click);
            this.label25.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.label25.BackColor = Color.Green;
            this.label25.Font = new Font("Tahoma", 16f);
            this.label25.ForeColor = Color.White;
            this.label25.Location = new Point(0, 0);
            this.label25.Name = "label25";
            this.label25.Size = new Size(0x2de, 0x2d);
            this.label25.TabIndex = 0x1a;
            this.label25.Text = "TH\x00d4NG SỐ";
            this.label25.TextAlign = ContentAlignment.MiddleLeft;
            this.xtraTabControl1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.xtraTabControl1.Location = new Point(0, 0x2f);
            this.xtraTabControl1.Name = "xtraTabControl1";
            this.xtraTabControl1.SelectedTabPage = this.tabkhambenh;
            this.xtraTabControl1.Size = new Size(0x2db, 340);
            this.xtraTabControl1.TabIndex = 0x1b;
            this.xtraTabControl1.TabPages.AddRange(new XtraTabPage[] { this.tabkhambenh });
            this.tabkhambenh.Controls.Add(this.txta4);
            this.tabkhambenh.Controls.Add(this.label5);
            this.tabkhambenh.Controls.Add(this.label2);
            this.tabkhambenh.Controls.Add(this.cbbdangnhap);
            this.tabkhambenh.Controls.Add(this.chkcm_a3);
            this.tabkhambenh.Controls.Add(this.chkcm_a2);
            this.tabkhambenh.Controls.Add(this.chkcm_a1);
            this.tabkhambenh.Name = "tabkhambenh";
            this.tabkhambenh.Size = new Size(0x2d5, 0x138);
            this.tabkhambenh.Text = "Chuy\x00ean m\x00f4n";
            this.label2.Font = new Font("Tahoma", 10f);
            this.label2.Location = new Point(1, 290);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x7b, 0x13);
            this.label2.TabIndex = 4;
            this.label2.Text = "T\x00ean đăng nhập:";
            this.label2.TextAlign = ContentAlignment.TopRight;
            this.cbbdangnhap.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.cbbdangnhap.Location = new Point(0x7c, 0x11f);
            this.cbbdangnhap.Name = "cbbdangnhap";
            this.cbbdangnhap.Properties.Appearance.Font = new Font("Tahoma", 10f);
            this.cbbdangnhap.Properties.Appearance.Options.UseFont = true;
            this.cbbdangnhap.Properties.AutoSearchColumnIndex = 1;
            this.cbbdangnhap.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cbbdangnhap.Properties.Columns.AddRange(new LookUpColumnInfo[] { new LookUpColumnInfo("id", "id", 20, FormatType.None, "", false, HorzAlignment.Default), new LookUpColumnInfo("tennguoidung", "T\x00ean"), new LookUpColumnInfo("tendangnhap", "T\x00ean đăng nhập") });
            this.cbbdangnhap.Properties.DropDownRows = 10;
            this.cbbdangnhap.Properties.HeaderClickMode = HeaderClickMode.AutoSearch;
            this.cbbdangnhap.Properties.HideSelection = false;
            this.cbbdangnhap.Properties.HighlightedItemStyle = HighlightStyle.Standard;
            this.cbbdangnhap.Properties.NullText = "";
            this.cbbdangnhap.Properties.PopupSizeable = false;
            this.cbbdangnhap.Size = new Size(0x256, 0x16);
            this.cbbdangnhap.TabIndex = 3;
            this.cbbdangnhap.EditValueChanged += new EventHandler(this.cbbdangnhap_EditValueChanged);
            this.chkcm_a3.AutoSize = true;
            this.chkcm_a3.Checked = true;
            this.chkcm_a3.CheckState = CheckState.Checked;
            this.chkcm_a3.Font = new Font("Tahoma", 10f);
            this.chkcm_a3.Location = new Point(4, 0x3b);
            this.chkcm_a3.Name = "chkcm_a3";
            this.chkcm_a3.Size = new Size(0x17a, 0x15);
            this.chkcm_a3.TabIndex = 2;
            this.chkcm_a3.Text = "A3. Sửa th\x00f4ng tin h\x00e0nh ch\x00ednh của bệnh nh\x00e2n khi tiếp đ\x00f3n";
            this.chkcm_a3.UseVisualStyleBackColor = true;
            this.chkcm_a2.AutoSize = true;
            this.chkcm_a2.Checked = true;
            this.chkcm_a2.CheckState = CheckState.Checked;
            this.chkcm_a2.Font = new Font("Tahoma", 10f);
            this.chkcm_a2.Location = new Point(4, 0x24);
            this.chkcm_a2.Name = "chkcm_a2";
            this.chkcm_a2.Size = new Size(0x145, 0x15);
            this.chkcm_a2.TabIndex = 2;
            this.chkcm_a2.Text = "A2. Cấp toa thuốc nội viện (c\x00f3 quản l\x00ed kho dược)";
            this.chkcm_a2.UseVisualStyleBackColor = true;
            this.chkcm_a1.AutoSize = true;
            this.chkcm_a1.Checked = true;
            this.chkcm_a1.CheckState = CheckState.Checked;
            this.chkcm_a1.Font = new Font("Tahoma", 10f);
            this.chkcm_a1.Location = new Point(4, 13);
            this.chkcm_a1.Name = "chkcm_a1";
            this.chkcm_a1.Size = new Size(0xcd, 0x15);
            this.chkcm_a1.TabIndex = 2;
            this.chkcm_a1.Text = "A1. Cấp toa thuốc ngoại viện";
            this.chkcm_a1.UseVisualStyleBackColor = true;
            this.txta4.EditValue = "1";
            this.txta4.Location = new Point(0x107, 0x56);
            this.txta4.Name = "txta4";
            this.txta4.Properties.Appearance.Options.UseTextOptions = true;
            this.txta4.Properties.Appearance.TextOptions.HAlignment = HorzAlignment.Far;
            this.txta4.Size = new Size(0x22, 20);
            this.txta4.TabIndex = 20;
            this.label5.Font = new Font("Tahoma", 10f);
            this.label5.Location = new Point(3, 0x57);
            this.label5.Name = "label5";
            this.label5.Size = new Size(0x103, 0x13);
            this.label5.TabIndex = 0x13;
            this.label5.Text = "A4. Số ng\x00e0y bệnh nh\x00e2n chờ kh\x00e1m bệnh:";
            this.label5.TextAlign = ContentAlignment.TopRight;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.xtraTabControl1);
            base.Controls.Add(this.label25);
            base.Controls.Add(this.btnluu);
            base.Controls.Add(this.btnketthuc);
            this.LookAndFeel.UseWindowsXPTheme = true;
            base.Name = "ucbn_thongso";
            base.Size = new Size(0x2de, 0x1a3);
            base.Load += new EventHandler(this.UCphanquyensudung_Load);
            this.xtraTabControl1.EndInit();
            this.xtraTabControl1.ResumeLayout(false);
            this.tabkhambenh.ResumeLayout(false);
            this.tabkhambenh.PerformLayout();
            this.cbbdangnhap.Properties.EndInit();
            this.txta4.Properties.EndInit();
            base.ResumeLayout(false);
        }

        private void UCphanquyensudung_Load(object sender, EventArgs e)
        {
            if (this._condata == null)
            {
                this._condata = new ConnectDatabase();
            }
            this._tsbn = new BNThongSo(this._condata);
            this.f_loaddata_dmdangnhap();
            this.cbbdangnhap.ItemIndex = 0;
        }

        public ConnectDatabase pCondata
        {
            get
            {
                return this._condata;
            }
            set
            {
                this._condata = value;
            }
        }
    }
}

